<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑文章</title>
    <link rel="stylesheet" type="text/css" href="index.css">
    <script type="text/javascript" src="../js/url.js"></script>
    <script type="text/javascript" charset="utf-8" src="jquery-2.1.4.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="ueditor.all.js"> </script>
    <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script>
     <script type="text/javascript" charset="utf-8" src="edit.js"></script>
    
</head>
<body>
<div id="content">
    <div class="titleText">
        标题：<input type="text" id="articleTitle" required/>
    </div>

    <script id="editor" type="text/plain" style="height:480px;"></script>

    <div class="tip">
        <span>标签：</span>
        <input type="text" id="articleTip" />
        <span>&nbsp;为你的文章添加标签，用英文","隔开，最多添加五个</span>
    </div>

    <input type="button" id="send" value="确认发表"/>

</div>

<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

    // 判断编辑器是否有内容
    function hasContent() {
       var hasContent = UE.getEditor('editor').hasContents();
       return hasContent;
    }

    // 获得纯文本
    function getContentTxt() {
       var contentText1 = UE.getEditor('editor').getContentTxt();
       var contentText2 = contentText1.trim();
       var contentText = contentText2.slice(0,250) + "..." ;
       return contentText;
    }

    // 获得带标签的文章内容
    function getContent() {
        var content = UE.getEditor('editor').getContent();
        return content;
    }
    
    //写入内容
    function setContent(title,content,tag) {
        UE.getEditor('editor').setContent(content);
        $("#articleTitle").val(title);
        $("#articleTip").val(tag);
    }

</script>
</body>
</html>
